<template>
  <view></view>
</template>
<script>
// home页用于页面跳转，当用户登录了以后，跳转到首页，否则跳转到授权页
import { getUserInfoByPatientId } from '@/api/join';
export default {
  data() {
    return {};
  },
  onLoad() {
    let token = wx.getStorageSync('token');
    let patientId = wx.getStorageSync('patientid');
    if (token && patientId) {
      // 用户已登录,判断用户是否实名认证。实名认证跳到首页，否则跳实名认证页面
      getUserInfoByPatientId(patientId).then((res) => {
        if (res.code === 0 && res.data && res.data.realNameAuthenticationPassed === 1) {
          setTimeout(() => {
            uni.redirectTo({
              url: 'pages/index/index',
              animationType: 'none'
            });
          }, 0);
        } else {
          // 跳实名认证页面
          setTimeout(() => {
            uni.redirectTo({
              url: 'pages/index/index',
              animationType: 'none'
            });
            // uni.redirectTo({
            //   url: 'pages/join/authorIdentityChaeck',
            //   animationType: 'none'
            // });
          }, 0);
        }
      });
    } else {
      // 用户未登录
      this.gotoJoin();
    }
  },
  methods: {
    gotoJoin() {
      console.log('gottojoin');
      setTimeout(() => {
        uni.redirectTo({
          url: 'pages/index/index',
          animationType: 'none'
        });
      }, 0);
    }
  }
};
</script>
